/** ###################################################################
**     Filename  : Lights.c
**     Project   : parking
**     Processor : MC9S12XS128MAL
**     Compiler  : CodeWarrior HCS12X C Compiler
**     Date/Time : 2013-3-31, 14:47
**     Contents  :
**         User source code
**
** ###################################################################*/

/* MODULE Lights */

#include "Lights.h"

bool LTLeftSwitch = FALSE;
bool LTRightSwitch = FALSE;
bool LTStopSwitch = FALSE;

void LTStopOn(void){
	LTStopSwitch = TRUE;
	LT_STOP_LEFT_SetVal();			
	LT_STOP_RIGHT_SetVal();
}
void LTStopOff(void){
	LTStopSwitch = FALSE;
	LT_STOP_LEFT_ClrVal();			
	LT_STOP_RIGHT_ClrVal();	
}
void LTLeftOn(void){
	LTLeftSwitch = TRUE;	
}
void LTRightOn(void){
	LTRightSwitch = TRUE;	
}
void LTLeftOff(void){
	LTLeftSwitch = FALSE;	
}
void LTRightOff(void){
	LTRightSwitch = FALSE;	
}
void LTTimerHandler(void){
	static U8 count = 0;
	if ((count / 2) % 2 == 0){
		if (LTRightSwitch){
			LT_RIGHT_SetVal();	
		}
		if (LTLeftSwitch){
			LT_LEFT_SetVal();		
		}
	}else{
		LT_RIGHT_ClrVal();
		LT_LEFT_ClrVal();	
	}
	count++;
}

void LTAllOff(void){
	LTStopOff();
	LTLeftOff();
	LTRightOff();	
}
void LTDoubleFlash(void){
	LTLeftOn();
	LTRightOn();
}
void LTLightUponDir(S16 dir){
	if (dir > 0){
		LTLeftOff();
		LTRightOn();		
	}else if (dir < 0){
		LTRightOff();
		LTLeftOn();	
	}	
	
}

/* END Lights */
